package com.zzyl.controller;


import com.zzyl.base.PageResponse;
import com.zzyl.base.ResponseResult;
import com.zzyl.dto.NursingProjectDto;
import com.zzyl.entity.NursingProject;
import com.zzyl.service.NursingProjectService;
import com.zzyl.vo.NursingProjectVo;
import io.swagger.annotations.*;
import lombok.extern.slf4j.Slf4j;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/nursing_project")
@Api(tags = "护理项目管理")
@Slf4j
public class NursingProjectController {

    @Autowired
    private NursingProjectService nursingProjectService;


    /**
     * 护理项目Controller类
     */


    @GetMapping
    @ApiOperation("分页查询护理项目列表")
    public ResponseResult<PageResponse<NursingProjectVo>> getByPage(
            @ApiParam(value = "护理项目名称")
            @RequestParam(value = "name", required = false) String name,
            @ApiParam(value = "状态：0-禁用，1-启用")
            @RequestParam(value = "status", required = false) Integer status,
            @ApiParam(value = "当前页码")
            @RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,
            @ApiParam(value = "每页显示数量")
            @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize) {
        log.info("分页查询护理项目信息：name:{}，status:{}，pageNum:{}，pageSize:{}", name, status, pageNum, pageSize);

        PageResponse<NursingProjectVo> nursingProjectPageInfo = nursingProjectService.getByPage(name, status, pageNum, pageSize);
        return ResponseResult.success(nursingProjectPageInfo);
    }

    @PostMapping
    @ApiOperation(value = "新增护理项目")
    public ResponseResult addNursingProject(
            @ApiParam(value = "护理项目数据传输对象", required = true)
            @RequestBody NursingProjectDto nursingProjectDto) {
        nursingProjectService.addNursingProject(nursingProjectDto);
        return ResponseResult.success();
    }

    @GetMapping("/{id}")
    @ApiOperation(value = "根据id查询护理项目")
    public ResponseResult <NursingProjectVo> GetbyidNursingProject(@PathVariable("id") Long id) {

        NursingProjectVo nursingProjectVo =nursingProjectService.getNursingProject(id);

     return ResponseResult.success(nursingProjectVo);
    }
    //修改护理项目
    @PutMapping
    @ApiOperation(value = "根据id修改护理项目")
public ResponseResult updateNursingProject(@RequestBody  NursingProjectDto nursingProjectDto){
        nursingProjectService.updateNursingProject(nursingProjectDto);

        return ResponseResult.success();
}

}






